#ifndef __STEP_MOTOR_GPIO_H
#define __STEP_MOTOR_GPIO_H


#include "stm32f4xx.h"
#include "motor_task.h"
//#include "motor.h"

//typedef struct
//{
//    uint16_t ecd;           //转子机械角度
//    int16_t  speed_rpm;      //转子转速
//    int16_t  given_current;  //实际转矩电流(此处为PWM)
//    uint8_t  temperate;      //电机温度
//    int16_t  last_ecd;       //上次转子机械角度
//} motor_measure_t;

#define       EN1_Pin          GPIO_Pin_0                    //PC0
#define       STEP1_Pin        GPIO_Pin_2                    //PC2
#define       DIR1_Pin         GPIO_Pin_1                    //PC1

#define       EN2_Pin          GPIO_Pin_3                    //PC3
#define       STEP2_Pin        GPIO_Pin_4                    //PA4
#define       DIR2_Pin         GPIO_Pin_5                    //PA5


#define       EN1_H            (GPIOC->BSRR = EN1_Pin)              							//PC0
#define       EN1_L            (GPIOC->BSRR = (uint32_t)EN1_Pin << 16)

#define       STEP1_H          (GPIOC->BSRR = STEP1_Pin)              							//PC2
#define       STEP1_L          (GPIOC->BSRR = (uint32_t)STEP1_Pin << 16)
#define       STEP1_TOGGLE     (GPIOC->ODR ^= STEP1_Pin)

#define       DIR1_H           (GPIOC->BSRR = DIR1_Pin)              							//PC1
#define       DIR1_L           (GPIOC->BSRR = (uint32_t)DIR1_Pin << 16)

#define       EN2_H            (GPIOC->BSRR = EN2_Pin)              							//PC3
#define       EN2_L            (GPIOC->BSRR = (uint32_t)EN2_Pin << 16)

#define       STEP2_H          (GPIOA->BSRR = STEP2_Pin)              							//PA4
#define       STEP2_L          (GPIOA->BSRR = (uint32_t)STEP2_Pin << 16)
#define       STEP2_TOGGLE     (GPIOA->ODR ^= STEP2_Pin)

#define       DIR2_H           (GPIOA->BSRR = DIR2_Pin)              							//PA5
#define       DIR2_L           (GPIOA->BSRR = (uint32_t)DIR2_Pin << 16)


void step_motor_init(void);
#endif
